$(() => {
    $("#uploadBtn").click(() => {
        let formData = new FormData($("#upload")[0]);
        $("#main").addClass("el-loading");
        $.ajax({
            type: 'post',
            url: url,
            data: formData,
            cache: false,
            processData: false,
            contentType: false,
            success: data => {
                $("#avatar").attr("src", data);
                $("#main").removeClass("el-loading");
                dialog("提示","头像上传成功");
                console.log(data);
            },
            error: () => {
                $("#main").removeClass("el-loading");
                dialog("错误","上传失败");
            }
        });
    });
    $("#btn1").click(() => {
        $("#main").addClass("el-loading");
        let avatar = $("#avatar").attr("src");
        let nickname = $("#nickname").val();
        let gender=$("#gender").val();
        let age=$("#age").val();
        let description=$("#description").val();
        $.post("#",{
            avatar:avatar,
            nickname:nickname,
            gender:gender,
            age:age,
            description:description
        },text=>{
            $("#main").removeClass("el-loading");
            let data=JSON.parse(text);
            if(data.status){
                dialog("提示",data.msg);
                setTimeout(() => {
                    location.href="{LINK_user}";
                }, 1000);
            }else{
                dialog("错误","设置失败："+data.msg);
            }
        });
    });
});